package com.chengwei.ch.busdemo.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chengwei.ch.busdemo.R;
import com.chengwei.ch.busdemo.adapter.SettingAdapter;
import com.chengwei.ch.busdemo.base.BaseActivity;
import com.chengwei.ch.busdemo.view.TitleView;

import java.util.ArrayList;
import java.util.List;

@SuppressLint("Registered")
public class SettingActivity extends BaseActivity {

    private LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
    private SettingAdapter mSettingAdapter;
    private List<String> listSite;

    private RecyclerView rvList;
    private TitleView titleBack;
    private Button btnExit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        initView();
        initClickListener();
        initRecycler();
    }


    private void initView() {
        titleBack = findViewById(R.id.titleBackSetting);
        btnExit = findViewById(R.id.btnExitSetting);
        rvList = findViewById(R.id.rvListSetting);
    }


    private void initClickListener() {
        titleBack.addTitleLeftOnClickListener(this);
        btnExit.setOnClickListener(this);
    }

    private void initRecycler() {
        listSite = new ArrayList<>();
        listSite.add("人脸识别");
        listSite.add("体温检测");
        listSite.add("口罩检测");
        listSite.add("乘客身份证验证");
        listSite.add("会员卡消费");
        listSite.add("人脸照片对比");
        listSite.add("版本号V1.1");
        listSite.add(".....");
        mSettingAdapter = new SettingAdapter(R.layout.item_setting, listSite);
        rvList.setLayoutManager(mLinearLayoutManager);
        rvList.setAdapter(mSettingAdapter);
        mSettingAdapter.setNewData(listSite);
        mSettingAdapter.setOnItemChildClickListener((adapter, view, position) -> {
            if (view.getId() == R.id.tvActivationSetting) {
                Intent intent = new Intent();
                intent.setClass(SettingActivity.this, ActivationActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.IBtnTitleViewLeftBack: {
                finish();
                break;
            }
            case R.id.btnExitSetting: {
                finish();
                break;
            }
            default:
                break;
        }
    }
}
